{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "from fractions import Fraction\n",
    "from scipy.special import comb"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "l = 30\n",
    "coeffs = [0] * l\n",
    "coeffs[1] = 1\n",
    "for k in range(2, l):\n",
    "    for i in range(1, k):\n",
    "        coeffs[k] += Fraction(-1 * coeffs[i] * comb(k - 1, i - 1, exact=True), k - i + 1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1,\n",
       " Fraction(-1, 2),\n",
       " Fraction(1, 6),\n",
       " Fraction(0, 1),\n",
       " Fraction(-1, 30),\n",
       " Fraction(0, 1),\n",
       " Fraction(1, 42),\n",
       " Fraction(0, 1),\n",
       " Fraction(-1, 30),\n",
       " Fraction(0, 1),\n",
       " Fraction(5, 66),\n",
       " Fraction(0, 1),\n",
       " Fraction(-691, 2730),\n",
       " Fraction(0, 1),\n",
       " Fraction(7, 6),\n",
       " Fraction(0, 1),\n",
       " Fraction(-3617, 510),\n",
       " Fraction(0, 1),\n",
       " Fraction(43867, 798),\n",
       " Fraction(0, 1),\n",
       " Fraction(-174611, 330),\n",
       " Fraction(0, 1),\n",
       " Fraction(854513, 138),\n",
       " Fraction(0, 1),\n",
       " Fraction(-236364091, 2730),\n",
       " Fraction(0, 1),\n",
       " Fraction(8553103, 6),\n",
       " Fraction(0, 1),\n",
       " Fraction(-23749461029, 870)]"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "coeffs[1:]"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
